package com.core.website.api;

import com.core.website.common.Result;
import com.core.website.common.ResultUtil;
import com.core.website.entity.CoreUnit;
import com.core.website.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/unitApi")
public class UnitApi {
    @Autowired
    private UnitService unitService;
    @PostMapping("/add")
    public Result add(@RequestBody CoreUnit coreUnit){
        int result=unitService.add(coreUnit);
        return ResultUtil.success(result);
    }
    @PostMapping("/edit")
    public Result edit(@RequestBody CoreUnit coreUnit){
        int result=unitService.edit(coreUnit);
        return ResultUtil.success(result);
    }
    @PostMapping("/delete")
    public Result delete(@RequestBody List<String> ids){
        int result=unitService.delete(ids);
        return ResultUtil.success(result);
    }
    @PostMapping("/queryAll")
    public Result queryAll(@RequestBody CoreUnit coreUnit){
        List<CoreUnit> result=unitService.queryAll(coreUnit);
        return ResultUtil.success(result);
    }
    @GetMapping("/queryOne")
    public Result queryOne(String id){
        CoreUnit result=unitService.queryOne(id);
        return ResultUtil.success(result);
    }
}
